//
//  AnswerView.swift
//  Maze24
//
//  Created by Mars on 2020/12/5.
//

import SwiftUI

struct AnswerView: View {
  @Environment(\.presentationMode) var presentation
  
  let title: String = "一个可能的计算结果是..."
  let subtitle: String = "下次要争取自己完成喔"
  let answer: String
  let wizard: Image = Image("wizard")
  
  var body: some View {
    VStack(spacing: 20) {
      Text(title)
        .font(.largeTitle)
        .padding(.bottom, 40)
        .lineLimit(1)
        .minimumScaleFactor(0.8)
      
      Text(answer)
        .font(Font.system(size: 30, design: .monospaced))
        .fontWeight(.semibold)
        .lineLimit(1)
        .minimumScaleFactor(0.6)
        
        .frame(maxWidth: .infinity)
        .foregroundColor(.white)
        .background(Color.blue)
      
      HStack {
        Text(subtitle).font(.body).foregroundColor(.gray)
        Spacer()
      }
      .padding(.leading)
      .offset(y: 70)
      
      wizard.resizable().scaledToFit().padding(20)
      
      Spacer()
      
      Button("返回") {
        self.presentation.wrappedValue.dismiss()
      }
    }
    .padding(.top, 20)
  }
}

struct AnswerView_Previews: PreviewProvider {
  static var previews: some View {
    AnswerView(answer: "((2-3)×6+1))")
  }
}
